To keep things simple, we'll use embedded styles instead of creating a separate style sheet file. Start by opening the file /tutorial files/tour2.htm and reviewing the HTML code. You will notice that most of the attribute code from tour.htm has been removed, leaving just the structural elements -- <BODY>, <P>, <H1>, <TABLE>, <UL>
-- and some formatted content. This an essential first step in moving to the new formatting method.
To make it easier to follow along, the stripped attributes are shown in code comments above each tag on the page. The browser skips these comments when rendering the page, so the code contained in them will not affect the formatting.
Click the Browse tab to see what the page looks like at this point.
We'll begin by entering a <STYLE>
block in the <HEAD>
section of the document. We will then open TopStyle and work our way through the page code and insert the new style rules when they are completed.
![]() |
To add a style block to a document: |
<STYLE></STYLE
> tags just above the </HEAD>
tag in the tour2.htm file.
HomeSite uses the TopStyle Lite CSS editor from Bradbury Software. It has a specialized interface to makes creating and editing style sheets easy. The online Help is a good resource for learning about TopStyle features and CSS.
We are now ready to create our style rules.
![]() |
To add BODY properties: |
This completes the BODY properties style. No change is needed to the <BODY>
tag in the document.
Standard HTML uses tags such as <B>
, <EM>
, and <STRONG>
to highlight text. With styles, you set special formatting for words (or characters) by enclosing them in the <SPAN></SPAN>
tag and applying styles. For formatting paragraphs and larger content blocks, use the <DIV></DIV>
tag.
We might want to use bold formatting in different situations, not attached to a particular selector, so we'll define a class for the bold property that can be applied wherever we need it. Classes can stand alone or be part of a selector. We'll explore their use in several sections of the page.
![]() |
To create a standalone class: |
The bold class displays in the style list.
The style can now be applied in the document.
<SPAN class="bold">
HomeSite</SPAN>
, which you can find at..."
You can set properties for the A selector, such as colors for active and visited links, but we'll just accept the browser defaults.
This image link does not require a style.
The Heading 1 tag uses the default font size set by the browser and inherits the font color value from the BODY style.
![]() |
To add horizontal rule properties: |
No change is needed in the <HR>
tag in the document.
The Line Break tag does not take styles.
You could set a single paragraph style for an entire site, but the real power of styles is that they make it possible to create and apply a virtually unlimited library of design ideas, through the use of classes.
For example, you could define individual paragraph classes for introductory text, important notes, and contact information. Setting font faces, colors, and alignment for each of these content types would enhance the look of the site and make it easier for visitors to find what they are looking for.
As we saw in the bold formatting procedure above, we can create a standalone class and apply to different selectors. Here, we'll create a class just for the <P>
tag.
![]() |
To create a special paragraph style: |
The selector should now read "P.red".
<P>
tag to read "<P class="red">
".
At this point, you may be thinking that this is a lot of work to do for something you can just as easily do with tag attributes and you'd be right -- if we were only doing it for this page.
Cascading Style Sheets evolved as a response to the explosion of Internet content and the demand for a technology that enables the creation and maintenance of sites that contain lots of pages and complex page layout schemes.
Style sheets are a Web designer's dream because they allow you to make rapid and dramatic changes to all the HTML elements in a site. That means you can preview text, color, and layout designs by simply editing their styles.
Another advantage of formatting pages with style sheets is that by reducing the amount of code required to format each page, the pages can be downloaded and read by the browser more quickly.
An additional and very powerful capability is the use of scripts to manipulate styles and other document objects. The combination of styles, scripting, and HTML is known as Dynamic HTML (DHTML). If you want to work with DHTML, there are many print and Web references available on the subject.
As noted in the introduction to this tutorial, though, there are a number of browser inconsistencies that limit the full and unrestricted implementation of HTML elements, Cascading Style Sheets, and scripts. To prove it, just take a look at the completed tour_style.htm file in Netscape Navigator. You will need to be aware of how best to use these technologies in your site. It comes down to deciding which browsers and which browser versions you will support and then informing yourself about cross-browser design strategies.
As we continue with the tutorial, keep in mind that as great as style sheets can be, they come with some restrictions.
We'll complete this tutorial by applying styles to our page's most complex element, the table.
![]() |
To add a table style: |
padding
property, type in 3px
and press Enter.
border
property, select thin
.
border-style
property, select solid
.
We'll leave the CELLSPACING
attribute as is in the document. No changes are needed in the <TABLE>
tag.
No styles are needed for the table row <TR>
tag or for the first table data <TD>
tag.
No styles are needed for the list elements or for the paragraph that follows.
This next procedure is somewhat lengthy because in steps 6-9 we apply styles to the cell borders that are not affected by the <TABLE>
border properties. The method is rather crude but it spares us a discussion of style rules for tables, which is really beyond the scope of this tutorial. See the "Tables and Style Sheets" topic in the online HTML Reference for details.
![]() |
To add a table data style: |
TD
from the HTML Element list.
The TD.top
style appears in the style list.
text-align
property, select center
.
font-weight
property, select bold
.
Since all the text in the table cell is bold, we don't need to wrap it in a <SPAN>
tag.
background-color
property, select Yellow
.
border-left-style
property, select solid
.
border-left-width
property, select thin
.
border-bottom-style
property, select solid
.
border-bottom-width
property, select thin
.
<TD class="top">.
We're almost done. We just need to define styles for the last table cell.
![]() |
To add additional table data styles: |
TD.bottom
class.
text-align
and font-weight
properties as you did in TD.top
.
background-color
property, select Lime
.
border-left
properties as you did in TD.top
.
<TD class="bottom">.